package cate.common.table.d;

import cate.common.table.common.ParamSheet;
import cate.common.util.TimeTool;
import easy.java.dev.note.NoteClass;
import easy.java.dev.note.NoteField;

import java.util.Arrays;
import java.util.List;

@NoteClass("王座争霸")
public class GDThrone {

	private GDThrone() {
	}

	@NoteField("赛季持续时间")
	public static final long WHOLE_SEASON_TIME = 28 * TimeTool.TimeCons.DAY;

	@NoteField("选拔赛初始积分")
	public static final int TRIAL_INIT_POINT = 5000;

	@NoteField("选拔赛挑战对手库人数上限")
	public static final int TRIAL_RIVAL_MAX = 256;

	@NoteField("选拔赛排行榜人数上限")
	public static final int TRIAL_RANK_MAX = 128;

	@NoteField("淘汰赛玩家匹配放入顺序")
	public static final int[] MATCH_POS_ORDER = {1, 5, 3, 7, 2, 6, 4, 8};

	@NoteField("录像保存天数")
	public static final int REPLAY_SAVE_DAY = 7;

	@NoteField("竞猜货币:交易货币倍率")
	public static double BET_RWD_COEFF;

	@NoteField("最大竞猜次数")
	public static int BET_MAX_TIME;

	@NoteField(value = "红包领取额度",detail = "也是单次竞猜额度")
	public static double BET_COIN;

	@NoteField("猜错保底奖励")
	public static long BET_FAIL_RWD;


	@NoteField("淘汰赛-分组塞轮次")
	public static final int KO_DIVIDE_ROUND = 1;
	@NoteField("淘汰赛-冠军对决轮次")
	public static final int KO_CHAMPION_ROUND = 8;

	@NoteClass("等级组")
	public static class LevelGroup {
		private LevelGroup() {
		}

		public static final int G1 = 1;
		public static final int G2 = 2;
		public static final int G3 = 3;

		public static List<Integer> ALL = Arrays.asList(G1,G2,G3);

		public static boolean valid(int group){
			return ALL.contains(group);
		}

	}


	@NoteClass("阶段")
	public static class Period {

		@NoteField("未开始或已结束")
		public static final byte NULL = 0;

		@NoteField(value = "准备", detail = "拉取段位赛玩家阵容作为选拔赛挑战数据")
		public static final byte PREPARE = 1;

		@NoteField("选拔赛")
		public static final byte TRIAL = 2;

		@NoteField("淘汰赛")
		public static final byte KO = 3;

		@NoteField("冠军boss")
		public static final byte CHAMPION_BOSS = 4;

		@NoteField("全服boss")
		public static final byte ZONE_BOSS = 5;


		public static byte getNextPeriod(byte p) {
			byte result = (byte) (p + 1);
			if (result > ZONE_BOSS || result < NULL) {
				return NULL;
			}
			return result;
		}


		public static String des(byte period) {
			switch (period) {
				case NULL:
					return "未开始或已结束";
				case PREPARE:
					return "准备阶段";
				case TRIAL:
					return "选拔赛阶段";
				case KO:
					return "淘汰赛阶段";
				case CHAMPION_BOSS:
					return "冠军BOSS挑战阶段";
				case ZONE_BOSS:
					return "全服BOSS挑战阶段";
				default:
					return "未知阶段";
			}
		}
	}

	@NoteClass("挑战对手等级")
	public static class TrialLevel {
		@NoteField("初级")
		public static final int LOW = 1;
		@NoteField("中级")
		public static final int MIDDLE = 2;
		@NoteField("高级")
		public static final int HIGH = 3;

		public static final List<Integer> ALL = Arrays.asList(LOW, MIDDLE, HIGH);
	}


	@NoteClass("王座争霸-淘汰赛类型")
	public static class KoGameType {
		@NoteField(value = "分组塞", detail = "128强划分入胜败组")
		public static final int DIVIDE = 1;
		@NoteField(value = "晋级赛")
		public static final int ADVANCE = 2;
		@NoteField(value = "冠军对决", detail = "胜者组败者组冠军比赛")
		public static final int CHAMPION = 3;
	}

	@NoteClass("王座争霸-淘汰赛-晋级赛分组类型")
	public static class KoGroupType {
		@NoteField("胜者组")
		public static final int WINNER = 1;
		@NoteField("败者组")
		public static final int LOSER = 2;
	}

	@NoteClass( "王座争霸-淘汰赛-匹配规则")
	public static class MatchRule {
		@NoteField("按照顺序任意分配")
		public static final int R0 = 0;
		@NoteField("初次分配 保障每个赛区都有人")
		public static final int INIT_RULE = 1;
		@NoteField("依据上一轮的分组情况进行匹配")
		public static final int LAST_ROUND = 2;
	}

	@NoteClass("王座争霸-淘汰赛阶段")
	public static class KoPeriod{
		@NoteField("未开始")
		public static final int NONE = 0;
		@NoteField("竞猜阶段")
		public static final int BET = 1;
		@NoteField("战斗计算阶段")
		public static final int CAL = 2;
		@NoteField("战斗阶段")
		public static final int FIGHT = 3;
		@NoteField("休息阶段")
		public static final int REST = 4;

		public static String des(int period) {
			switch (period) {
				case NONE:
					return "未开始";
				case BET:
					return "竞猜阶段";
				case CAL:
					return "战斗计算阶段";
				case FIGHT:
					return "战斗阶段";
				case REST:
					return "休息阶段";
				default:
					return "未知阶段";
			}
		}
	}


	/** 读取excel中配置的参数 */
	public static void initialize(ParamSheet paramSheet) {
		BET_RWD_COEFF = GDParamTool.getDouble(paramSheet, 521, 10);
		BET_MAX_TIME = GDParamTool.getInt(paramSheet, 522, 10);
		BET_COIN = GDParamTool.getDouble(paramSheet, 523, 300);
		BET_FAIL_RWD = GDParamTool.getLong(paramSheet, 524, 500L);
	}
}
